<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <ui:composition template="./template.xhtml">
        <ui:define name="content">
            <p:panel id="settingsPrivacy" header="Privacy" styleClass="middlePanel">
                <h:form>
                    <div>
                        <h:outputLabel for="visibility" value="Your calendar is currently "/>
                        <h:outputText id="visibility" value="#{userBean.calendarVisibility}" styleClass="calendar#{userBean.calendarVisibility}"/>
                    </div>
                    <p:commandButton action="#{userBean.changeCalendarVisibility()}" type="submit"
                                     update="visibility" value="Change visibility" />
                </h:form>
                <div>
                    Share your calendar with everyone! <br/>
                    Making your calendar public every registered user can see your events.
                    But if you want to keep secret all your events, just set it private!
                </div>
            </p:panel>
            
            <p:panel id="settingsExport" header="Export Calendar" styleClass="middlePanel">
                <h:form>
                    <div>
                        Exporting will allow you to download every event you see in your calendar.
                    </div>
                        <p:commandButton value="Export" ajax="false" 
                                         onclick="PrimeFaces.monitorDownload(start, stop);" 
                                         icon="ui-icon-arrowthick-1-s">
                            <p:fileDownload value="#{importExportBean.exportCalendar()}" />
                        </p:commandButton>
                </h:form>
            </p:panel>  
            
            <p:panel id="settingsImport" header="Import Calendar" styleClass="middlePanel">
                <div>
                        Import a calendar to see all those events in your homepage!
                </div>

                <h:form enctype="multipart/form-data">
                    <p:growl id="messages" showDetail="true" />
                    <p:fileUpload value="#{importExportBean.file}" mode="simple"
                                  allowTypes="/(\.|\/)(xml)$/"/>
                    <p:commandButton value="Import" ajax="false" icon="ui-icon-arrowthick-1-n"
                                     actionListener="#{importExportBean.importCalendar()}"/>
               </h:form>
            </p:panel>
        </ui:define>
    </ui:composition> 
</html>
